<template>
  <div>
    <h4>count的值为：{{ count }}</h4>
    <button @click="sub">-1</button>
    <button @click="subN">-N</button>
    <button @click="subAsync">-1 Async</button>
    <button @click="subNAsync(10)">-N Async</button>
  </div>
</template>
<script>
import { mapState, mapMutations, mapActions } from 'vuex'
export default {
  name: 'Sub',
  data() {
    return {}
  },
  computed: {
    // todo 将指定state里的数据映射为当前组件的计算属性
    ...mapState(['count']),
  },
  methods: {
    // todo 将指定mutations里的方法映射为当前组件的methods方法
    ...mapMutations(['sub', 'subN']),
    // todo 将指定action里的异步方法映射为当前组件的methods方法，可以直接调用
    ...mapActions(['subAsync', 'subNAsync']),
    // handleSub() {
    //   this.sub()
    // },
    // handleSubN() {
    //   this.subN(3)
    // },
  },
}
</script>
<style lang="" scoped></style>
